    
    //shake函数
    function shake(obj,attr,endFn) {
        var num = 0;
        var arr = [];
        for(var i=30; i>0; i-=2) {
            arr.push(i,-i);
        }
        arr.push(0);
        var pos = parseInt( getStyle(obj,attr) );
        clearInterval(obj.timer);
        obj.timer = setInterval( function () {
        obj.style[attr] = pos + arr[num] + "px";
        num++;
        if(num === arr.length) {
            clearInterval(obj.timer);
            if(endFn) {
                endFn();
            }
        }
        },80 )
    }
    
    //doMove函数
    function doMove(obj,attr,dir,target,endFn) {   //dir:代表方向是向前还是向后 target：代表目标点位置
        dir = parseInt(getStyle( obj, attr )) < target ? dir : -dir;
        clearInterval(obj.timer);
        obj.timer = setInterval( function () {
            var speed = parseInt( getStyle(obj,attr) ) + dir;
            if(speed > target&& dir >0) {  //专用于向前走
                speed = target;
            }
            if(speed < target&& dir < 0) { //专用于向后走
                speed = target;
            }
            obj.style[attr] = speed + "px";
            if(speed == target) {
                clearInterval(obj.timer);
                //回调函数
                if(endFn) {
                    endFn();
                }
            }
        },30 )
    }
     
    //getStyle函数
    function getStyle(obj,attr) {
        return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj)[attr];
    }